<%@ page pageEncoding="UTF-8"%>
<%@ include file="../commons/head.jsp"%>
<title>用户查询</title>
<style type="text/css">
	.button{width: 100px;height: 30px;margin:3px 20px 3px 0;padding-top: 3px;}
	*{font-size: 14px;}
	.th td{font-weight: 700;}
	/* label{margin: 0 10px 0 18px;font-weight: 500;height: 25px;line-height: 25px;} */
     .control-label{padding: 0;font-weight: bold;}
     .diaform{margin: 20px auto;}
     h3{border-bottom:1px solid #ddd;padding-bottom:5px;width: 98%;  }
     .datagrid-view{border-top:1px solid #ddd;margin-top: 8px;}
     .datagrid-pager{border-bottom:1px solid #ccc;}
     hr{margin:15px 0 13px 0 ;background-color: #ddd;height: 1px;border: 0; width: 120%;}
     .jianju{margin-left:15px; }
     .datagrid-htable{
     font-weight:bold;
	/* background-color: #148CCA; */
	}
	.demo_line_01{
    
    margin: 5px 0;
    font-size: 50px;
    line-height: 1px;
    text-align: center;
	}
	.demo_line_01 .line{
	display:inline-block;
	   width:47.8%;
	   height:1px;
	   background:#ddd;
	   vertical-align:middle;
	   margin-top:8px;
	}
	.container-fluid{
	padding-left: 15px;
	}
	.datagrid-ftable td div{
		font-size: larger;
	
	}
	#pulldown{
		margin-top: 20px;
	}
	
/* td.datagrid-header-over{
	background: #148CCA !important;
} */

.datagrid-ftable {
	color: red;
	font-weight: bold;
}
.datagrid-body {
height:300px !important;
}
.datagrid-view {
height:360px !important;
}


</style>

<script type="text/javascript">
	
$(function(){
	function scrollShow(datagrid) {
	    datagrid.prev(".datagrid-view2").children(".datagrid-body").html("<div style='width:" + datagrid.prev(".datagrid-view2").find(".datagrid-header-row").width() + "px;border:solid 0px;height:1px;'></div>");
	};
	scrollShow($("#yh"));
	
	$('#ssgs').combobox({
		onLoadSuccess : function() {
			var data = $('#ssgs').combobox('getData');
			if (data) {
				$("#ssgs").combobox('select', data[0].id);
			}
		}
	}); 
	
	$("#search").click(function(){
		var params = {
			userId:$("#userId").val(),
			userName:$("#userName").val(),
			underCompany:$("#ssgs").combobox("getValue"),
		};
		$("#yh").datagrid({url:"${ctx}/Boxuser/findlist",queryParams:params});
	});
	$("#add").click(function(){
		window.location.href="${ctx}/Boxuser/boxuseradd";
	});
});	

function showLinks1(value, row, index){
	var link="<a href='${pageContext.request.contextPath}/Boxuser/boxuseredit?id="+value+"'>修改</a>";
	return link;
}

function showLinks2(value, row, index){
	var link="<a href='${pageContext.request.contextPath}/Boxuser/boxuserdelete?id="+value+"'>删除</a>";
	return link;
}
function showLinks3(value, row, index){
	var link="<a href='${pageContext.request.contextPath}/Boxuser/boxuserinfo?userId="+value+"'>"+value+"</a>";
	return link;
}


function reload(closeFlag){
	/* if(reloadFlag){
		$("#forceAmount").form('clear');
	} */
	/* if(closeFlag){
		$("#dlg").dialog('close');
	} */
	$("#yh").datagrid('reload');
} 

 function closeDlg(){
	$("#yh").datagrid('reload');
	$('#dlg').dialog('close');
}; 

function rowStyle(index,row){
	if (index%2==0){     
        return 'background-color:lightcyan;';     
    }     
}

$(function(){
    $("#userId").textbox('textbox').bind('keyup', function(e){
	        $("#userId").textbox('setValue', $(this).val().replace(/\D/g,''));
    });
});

function formatMoney(number) {
number = Math.round(number * 100) / 100;
return outputDollars(Math.floor(number - 0) + '') + outputCents(number - 0);
}
function outputDollars(number) {
if (number.length <= 3)
	return (number == '' ? '0' : number);
else {
	var mod = number.length % 3;
	var output = (mod == 0 ? '' : (number.substring(0, mod)));
	for (i = 0; i < Math.floor(number.length / 3); i++) {
		if ((mod == 0) && (i == 0))
			output += number.substring(mod + 3 * i, mod + 3 * i + 3);
		else
			output += ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
	}
	return (output);
}
}
function outputCents(amount) {
amount = Math.round(((amount) - Math.floor(amount)) * 100);

if (amount == 10 || amount == 20 || amount == 30 || amount == 40
		|| amount == 50 || amount == 60 || amount == 70 || amount == 80
		|| amount == 90) {
	amount = (amount.toString()).substr(0, (amount.toString()).length - 1);
	return '.' + amount;
} else if (amount == 0) {
	return "";
} else if (amount == 1 || amount == 2 || amount == 3 || amount == 4
		|| amount == 5 || amount == 6 || amount == 7 || amount == 8
		|| amount == 9) {
	return '.0' + amount;
} else {
	return '.' + amount;
}

}
//鼠标悬停显示提示
function showTips(value, row, index) {
	var content = '';
	if(value != null && value != ''){
	    if(value.length>6 && strDateTime(value)){ //如果为时间
			value = value.substr(0,10);    	
	    }
	    content = '<span title="' + value + '" class="note" >' + value + '</span>';
	}
    return content;
}
function showMoneyTips(value, row, index) {
	var m = formatMoney(value,row,index);
    return showTips(m);
}
//判断是否为时间格式 yyyy-MM-dd HH:mm:ss
function strDateTime(str){
	var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; 
	var r = str.match(reg); 
	if(r==null)return false; 
	var d= new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]); 
	return (d.getFullYear()==r[1]&&
	(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7
	]);
}



</script>
</head>
<body style="height: 200%">
<div class="jianju" style="height: 1000px;">
<h3>用户查询</h3>

<div id="tb" style="padding:5px;height:auto">
	<hr/>
	<div>
	  <label style="margin-left:18px">客户手机：</label><input class="easyui-textbox" id="userId" type="number" style="width:120px">
	  <label style="margin-left:18px">客户姓名：</label><input class="easyui-textbox" id="userName" style="width:110px"><br />
	  <label style="margin-left:18px">所属公司：</label>
	    <select id="ssgs" class="easyui-combobox" style="width: 100px" 
			mode="remote" url="${ctx}/contractadvancedquery/findUnderCompany" valueField="id"
			textField="orgName" method="get" editable="false" panelHeight="auto">
		</select>
	</div>
	  <a id="search" href="#" class="easyui-linkbutton button" style="margin-left:15px;" iconCls="icon-search">查询</a>	
	  <a id="add" href="#" class="easyui-linkbutton button" iconCls="icon-add" plain="false">新增</a>
</div>

	<table id="yh" class="easyui-datagrid" 
		url=""
		title="" style="width:98%;minWidth:1000px;" 
		rownumbers="true" pagination="true"
		pageList="[3]" method="get"
		toolbar="#tb" singleSelect="true" pageSize="3"
		fitColumns="true" showFooter="true" rowStyler="rowStyle"
		onLoadSuccess:function(data){
                $(".note").tooltip({
                    onShow: function(){
                        $(this).tooltip('tip').css({ 
                            width:'300',
                            boxShadow: '1px 1px 3px #292929'       
                                             
                        });
                    }
                });
             } >
		<thead>
			<tr style="background:#148CCA;">
				<th data-options="field:'userId',align:'left',formatter:showLinks3" style="width:14%">登陆代码</th>
				<th data-options="field:'userName',align:'center',formatter:showTips" style="width:14%">用户姓名</th>
				<th data-options="field:'orgName',align:'center',formatter:showTips" style="width:14%">所属公司</th>
				<th data-options="field:'roleName',align:'center',formatter:showTips" style="width:14%">用户角色</th>
				<th data-options="field:'phone',align:'center',formatter:showTips" style="width:14%">联系电话</th>
				<th data-options="field:'editId',align:'center',formatter:showLinks1" style="width:14%">修改</th>
				<th data-options="field:'id',align:'center',formatter:showLinks2" style="width:14%">删除</th>
			</tr>
		</thead>
	</table>
	
</div>
</body>
</html>